Skip to content

Add perf kvm support#28

Open
ludfjig wants to merge 1 commit intomainfrom
perf_kvm_support
Open

Add perf kvm support#28
ludfjig wants to merge 1 commit intomainfrom
perf_kvm_support

Conversation

@ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Mar 2, 2026

This adds a simple wrapper around perf kvm which setups necessary things for getting function name resolution in the guets

@ludfjig ludfjig force-pushed the perf_kvm_support branch from 434a215 to dd7ed8f Compare March 2, 2026 23:38
Copy link

@dblnz dblnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a few comments and questions.

src/perf.rs Outdated
}

// Check perf_event_paranoid
if let Ok(val) = fs::read_to_string("/proc/sys/kernel/perf_event_paranoid")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some perf events are privileged and not accessible by default for any user

/// Build the common `perf kvm` argument prefix used by both record and report.
fn perf_kvm_args(args: &PerfArgs, kallsyms: &Path) -> Vec<OsString> {
let mut perf_args: Vec<OsString> = vec!["kvm".into()];
if args.host {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't provide --guest or --host it knows to only perf the guest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah should be accurate now. The wrapper doesn't have --guest, since it's the default

///
/// The iterator should start with the subcommand name ("perf"), which
/// clap consumes as the binary name (argv\[0\]).
pub fn run(args: impl Iterator<Item = OsString>) -> Result<()> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried stripping the debug symbols from the binary loaded in the guest, but provide the correct symbols to perf?
This would show a "realistic" load time for the hyperlight guest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't need debug symbols, it works with default rust release profile for example. It only needs function symbols

@ludfjig ludfjig force-pushed the perf_kvm_support branch from dd7ed8f to daa7d56 Compare March 3, 2026 19:55
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig force-pushed the perf_kvm_support branch from daa7d56 to d45edbc Compare March 3, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants